// app.js
var chatFun = require('./pages/fun_js/chat')
var mathFun = require('./pages/fun_js/math')


App({
  onLaunch() {
    // 展示本地存储能力
    var loginData = wx.getStorageSync('login_data')
    if (loginData != '') {
      this.globalData.userID = loginData.userID;
      this.globalData.OpenID = loginData.OpenID;
      this.globalData.LoginPhone = loginData.LoginPhone;
  
    }
    console.log( this.globalData.OpenID)
    // var chatlist =  chatFun.getTextMsg(this)
    // this.chatList.textTypeList = chatlist
    // var imglist= mathFun.getImgMsg(this)
    // this.chatList.imgTypeList = imglist
  },
  chatList:{
    textTypeList:[],
    imgTypeList:[]
  },
  globalData: {
    userInfo: null,
    saveloginData: undefined, //用于存储登录状态
    OpenID: '',
    LoginPhone: '',
    userID: '',
    useCount:0,
  },
  aibo:{
    aibo_id:'',
    webID:'',
    home:{}
  },
  tabBar:{},
  app_url: {
    // BASE_URL: 'https://genious.sitacloud.com',
    // SITA_BASE_URL: 'https://genious.sitacloud.com/question_search',
    BASE_URL: 'https://aibo.sitacloud.com',
    
    SITA_BASE_URL: 'https://aibo.sitacloud.com/question_search',
    SITA_PAY: '/wx_paybill',
    LOGIN:'/restful/wxmini/wxminilogon/',
    SITA_USE_COUNT: "/wx_walletupdate",
    SITA_ORC: '/mathocr_search',
    INVITE_CODE: '/gen_invitecode',
    LOGIN_CHECK: '/logonmenu_check',
    PAY_OPTIONS:'/payplans_fetch',
    AIBO_PAY:'/restful/wxmini/wxminipay2web/',
    AIBO_User_PAY:'/restful/wxmini/wxminipay2mini/',
    AIBO_WALLET:"/restful/wxmini/miniwalletinfo/",
    AIBO_HOME:"/restful/wxmini/wxminihomesummary/"
    
    
  },
  setCount(count){
    this.globalData.useCount = count
  },
  loginSuccess: function (logindata) {
    if (logindata != null) {
   
      this.globalData.OpenID = logindata.OpenID;
    }
    wx.setStorageSync('login_data', logindata)

  },
 
  saveTabItem(data){
    wx.setStorageSync("tab",data)
  },
  getTabItem(){
    var tabData = wx.getStorageSync('tab')
    if (tabData != '') {
      return tabData
    }
    return []
  },
  saveMsg(key,value){
    wx.setStorageSync(key, value)
  },
  getMsg(key){
    var saveData = wx.getStorageSync(key)
    if (saveData != '') {
      return saveData;
    }else{
      return []
    }
   
  }


})
